		TITLE	OUTDIN - Copyright (C) SLR Systems 1994

		INCLUDE	MACROS

if	V5

		INCLUDE	SYMBOLS
		INCLUDE	SEGMSYMS

		PUBLIC	OUTPUT_DIN,EXPORTED_TXT_LEN,EXPORTED_TXT


		.DATA

		EXTERNDEF	TEMP_RECORD:BYTE

		EXTERNDEF	IMP_DEVICE:DWORD,IMPDEF_FILE_GINDEX:DWORD,FIRST_ENTRYNAME_GINDEX:DWORD

		EXTERNDEF	ENTRYNAME_GARRAY:STD_PTR_S,SYMBOL_GARRAY:STD_PTR_S

		EXTERNDEF	IMP_OUTALL:DWORD


		.CODE	PASS2_TEXT

		EXTERNDEF	IMP_INIT:PROC,_flush_trunc_close:proc,CBTA16:PROC,CASE_STRING_COMPARE_HARD:PROC


OUTDIN_VARS	STRUC

ENTS_BP		ENT_STRUCT <>

OUTDIN_VARS	ENDS


FIX	MACRO	X

X	EQU	([EBP-SIZE OUTDIN_VARS].(X&_BP))

	ENDM


FIX	ENTS


OUTPUT_DIN	PROC
		;
		;IF REQUESTED, OUTPUT A .DIN FILE TO BE INCLUDED ON THE NEXT LINK TO KEEP ORDINAL #'S FROM
		;CHANGING.
		;
		MOV	EAX,IMPDEF_FILE_GINDEX
		GETT	CL,IMPDEF_FLAG

		OR	CL,CL
		JZ	L9$

		OR	EAX,EAX
		JZ	L9$

		PUSHM	EBP,EDI,ESI,EBX

		MOV	EBP,ESP
		ASSUME	EBP:PTR OUTDIN_VARS
		SUB	ESP,SIZE OUTDIN_VARS
		;
		;OPEN .DIN FILE
		;
		CALL	IMP_INIT

		MOV	IMP_DEVICE,EAX
		;
		;SEND 'EXPORTS' KEYWORD
		;
		MOV	EAX,OFF EXPORTS_TXT
		MOV	ECX,SIZEOF EXPORTS_TXT

		CALL	IMP_OUTALL
		;
		;OUTPUT EACH ENTRYNAME THAT IS DEFINED
		;
		MOV	ESI,FIRST_ENTRYNAME_GINDEX
		JMP	L8$

L9$:
		RET


L51$:
		CONVERT	ESI,ESI,ENTRYNAME_GARRAY
		ASSUME	ESI:PTR ENT_STRUCT
		;
		;OUTPUT EXPORTED NAME
		;
		MOV	ECX,[ESI]._ENT_NEXT_ENT_GINDEX
		MOV	AL,[ESI]._ENT_FLAGS

		PUSH	ECX
		TEST	AL,MASK ENT_UNDEFINED

		LEA	EDI,ENTS
		JNZ	L79$

		MOV	ECX,ENT_STRUCT._ENT_TEXT/4
		MOV	AL,'"'

		REP	MOVSD

		MOV	EDI,OFF TEMP_RECORD+1
		MOV	TEMP_RECORD,AL
L52$:
		MOV	AL,BYTE PTR[ESI]
		INC	ESI

		MOV	[EDI],AL
		INC	EDI

		OR	AL,AL
		JNZ	L52$

		LEA	ECX,[EDI-1]
		MOV	AL,ENTS._ENT_FLAGS

		MOV	EDI,ECX
		SUB	ECX,OFF TEMP_RECORD

		TEST	AL,MASK ENT_USE_EXTNAM
		JZ	L6$

		MOV	ESI,ENTS._ENT_UNDECO_GINDEX	;INTERNAL_NAME_GINDEX
		MOV	DPTR [EDI],'"="'

		CONVERT	ESI,ESI,SYMBOL_GARRAY
		;
		;SIMPLE IF EXACT MATCH, UNLESS USE_EXT IS SPECIFIED
		;
		ADD	ESI,SYMBOL_STRUCT._S_NAME_TEXT
		ADD	EDI,3
L57$:
		MOV	AL,BYTE PTR[ESI]
		INC	ESI

		MOV	[EDI],AL
		INC	EDI

		OR	AL,AL
		JNZ	L57$

		DEC	EDI
		MOV	EAX,ECX
L6$:
		MOV	BPTR [EDI],'"'
		INC	EDI
		;
		;SKIP IF ___EXPORTEDSTUB (ANY CASE)
		;
;		CMP	EAX,SIZEOF EXPORTED_TXT
;		JNZ	L61$
;
;		PUSH	EDI
;		MOV	ESI,OFF EXPORTED_TXT
;
;		MOV	EDI,OFF TEMP_RECORD+1
;		MOV	ECX,EAX
;
;		CALL	CASE_STRING_COMPARE_HARD
;		POP	EDI
;L61$:
		MOV	AL,ENTS._ENT_FLAGS
		MOV	ECX,'@ '

		TEST	AL,MASK ENT_ORD_SPECIFIED
		JZ	L63$

		MOV	[EDI],CL
		MOV	EAX,ENTS._ENT_ORD

		MOV	[EDI+1],CH
		LEA	ECX,[EDI+2]

		CALL	CBTA16			;OUTPUT IN DECIMAL

		MOV	EDI,EAX
		MOV	AL,ENTS._ENT_FLAGS
L63$:
		TEST	AL,MASK ENT_RESIDENTNAME
		JZ	L64$

		MOV	ESI,OFF RESNAM_TXT
		CALL	MOVER
L64$:
		TEST	AL,MASK ENT_NONAME
		JZ	L65$

		MOV	ESI,OFF NONAME_TXT
		CALL	MOVER
L65$:
		TEST	AL,MASK ENT_PRIVATE
		JZ	L66$

		MOV	ESI,OFF PRIV_TXT
		CALL	MOVER
L66$:
		TEST	AL,MASK ENT_NODATA
		JZ	L67$

		MOV	ESI,OFF NODATA_TXT
		CALL	MOVER
L67$:
		TEST	AL,MASK ENT_BYNAME
		JZ	L68$

		MOV	ESI,OFF BYNAME_TXT
		CALL	MOVER
L68$:
		MOV	AL,ENTS._ENT_PWORDS

		OR	AL,AL
		JZ	L69$

		XOR	AH,AH
		MOV	BPTR [EDI],' '

		LEA	ECX,[EDI+1]
		CALL	CBTA16

		MOV	EDI,EAX
L69$:
		MOV	DPTR [EDI],0A0DH
		LEA	ECX,[EDI+2]

		MOV	EAX,OFF TEMP_RECORD

		SUB	ECX,EAX
		CALL	IMP_OUTALL
L79$:
		POP	ESI
L8$:
		TEST	ESI,ESI
		JNZ	L51$
		;
		;FLUSH AND CLOSE .DIN FILE
		;
		MOV	EAX,IMP_DEVICE
		push	EAX
		call	_flush_trunc_close
		add	ESP,4

		MOV	ESP,EBP

		POPM	EBX,ESI,EDI,EBP

		RET

OUTPUT_DIN	ENDP


MOVER		PROC	NEAR
		;
		;
		;
		MOV	CL,BYTE PTR[ESI]
		INC	ESI

		AND	ECX,07FH

		REP	MOVSB

		RET

MOVER		ENDP


		.CONST

EXPORTS_TXT	DB	'EXPORTS',0DH,0AH
NODATA_TXT	DB	SIZEOF NODATA_TXT-1,' NODATA'
PRIV_TXT	DB	SIZEOF PRIV_TXT-1,' PRIVATE'
NONAME_TXT	DB	SIZEOF NONAME_TXT-1,' NONAME'
RESNAM_TXT	DB	SIZEOF RESNAM_TXT-1,' RESIDENTNAME'
BYNAME_TXT	DB	SIZEOF BYNAME_TXT-1,' BYNAME'

EXPORTED_TXT	DB	'___EXPORTEDSTUB'	;***

EXPORTED_TXT_LEN	EQU	$-EXPORTED_TXT

		DD	0			;***

endif

		END

